/*
** convert_base.c for  in /home/gueux_g/projet/code_source
**
** Made by gregory gueux
** Login   <gueux_g@epitech.net>
**
** Started on  Fri Oct 12 09:46:32 2012 gregory gueux
** Last update Thu May 16 14:35:03 2013 adrien lamaison
*/

#include "../include/my.h"

char	*convert_base(char *nbr, char *base_from, char *base_to)
{
  int   i;
  int   nb;
  char  *res;

  i = 0;
  res = xmalloc(sizeof(char) * 300);
  nb = my_getnbr_base(nbr, base_from);
  while (nb > 0)
    {
      res[i] = base_to[nb % my_strlen(base_to)];
      nb = nb / my_strlen(base_to);
      i = i + 1;
    }
  res[i] = '\0';
  res = my_revstr(res);
  return (res);
}
